version 14
set more off
set seed 1234

***************************************************************************************************
* THIS ROUTINE GENERATES FIGURE A.VIII AND A.IX OF WASEEM (2019) RESTAT
***************************************************************************************************

use				"$project_data\ExemptionCutoff_06_11.dta",clear
g				treat=(employee==0)

/* BINNING DATA */

local			var="seinc"
local			lbound=80000
local			ubound=500000
local 			binsize=20000
local 			nbin=(`ubound'-`lbound')/`binsize'			
local 			mf=`binsize'/1000							
keep 			`var' nsale ncost plexpenses imports openingstock closingstock regnor year treat regnor
g 				double z0=`var'
g 				z1=F1.`var'
g 				logchange=log(z1/z0)
keep 			if z0>80000 & z0<=500000
qui				sum logchange,d
drop			if (logchange<r(p1) | logchange>r(p99)) & year<2011
g 				bin=ceil(`var'/`binsize')
replace 		bin=bin*`mf'
drop			z0 z1 logchange

/* SALES */

preserve
local			var="nsale"
g 				double z0=`var'
g 				z1=F1.`var'
g 				logchange=log(z1/z0)
forvalues		y=2008/2010 {
				local m=substr("`y'",3,2)
g				treat_`m'=(year==`y' & treat==1)
g				cdellogincdd_`m'=0
g				se_`m'=0
g				cil_`m'=0
g				cih_`m'=0
}
g				cdellogincdd_0910=0
g				se_0910=0
g				trend=1
local			i=1
forvalues		y=2007/2011 {
local			i=`i'+1
replace			trend=`i' if year==`y'
}
g				treat_after=(treat==1 & year>2008)
forvalues		b=100(20)500 {
					qui reg logchange trend treat treat_09 treat_10 if bin==`b', cluster(regnor)
					forvalues y=2009/2010 {
						local m=substr("`y'",3,2)
						replace cdellogincdd_`m'=_b[treat_`m'] if bin==`b'
						replace cil_`m'=_b[treat_`m']-1.96*_se[treat_`m'] if bin==`b'
						replace cih_`m'=_b[treat_`m']+1.96*_se[treat_`m'] if bin==`b'
					}
					qui lincom treat_09+treat_10
					replace cdellogincdd_0910=r(estimate) if bin==`b'
					replace se_0910=r(se) if bin==`b'
}

*PLACEBO

forvalues		b=100(20)500 {
				qui reg	logchange trend treat treat_08 treat_09 treat_10 if bin==`b', cluster(regnor)
				replace cdellogincdd_08=_b[treat_08] if bin==`b'
				replace cil_08=_b[treat_08]-1.96*_se[treat_08] if bin==`b'
				replace cih_08=_b[treat_08]+1.96*_se[treat_08] if bin==`b'
}

* AGGREGATE

g 				cil_0910=cdellogincdd_0910-1.96*se_0910 
g 				cih_0910=cdellogincdd_0910+1.96*se_0910 
bys				bin year treat:g index=_n

/* 2010-11 */

#d				;
twoway  		(rarea cil_09 cih_09 bin if bin>80 & bin<=500 & index==1,sort color(gs13))
				(connected  cdellogincdd_09 bin if bin>80 & bin<=500 & index==1,sort clcolor(red) mcolor(red) msymbol(O) msize(large) lwidth(thick))
				(pcarrowi -0.6 170 -0.6 100, lcolor(black) mcolor(black))
				(pcarrowi -0.6 230 -0.6 300, lcolor(black) mcolor(black))
				(pcarrowi -0.6 300 -0.6 350, lcolor(black) mcolor(black))
				(pcarrowi 0.6 420 0.6 400, lcolor(black) mcolor(black))
				(pcarrowi 0.6 480 0.6 500, lcolor(black) mcolor(black)),
				xtitle(Self-Employment Income in PKR 000s) xtitle(, alignment(top))
				xlabel(100(50)500)
				xline(300, lcolor(maroon) lwidth(thick) lpattern(longdash))
				xline(350, lcolor(green) lwidth(thick) lpattern(longdash))
				xline(400 500, lpattern(dash) lcolor(gs5))
				ytitle(Difference-in-Differences Coefficient) yscale(titlegap(*10))
				ylabel(-0.8(0.4)0.8)
				text(0.6 450 "Not-to-zero""tax change")
				text(-0.6 200 "To-zero""tax changes")
				legend(region(style(none)) label(1 "95% Confidence Interval") label(2 "Coefficient") 
				rows(1) order(2 1)) 
				graphregion(fcolor(white) style(none) color(white) margin(0 2 0 2)) bgcolor(white);
				graph export "$project_graph\FigureAVIIIPanelA.eps", replace;
#d 				cr

/* 2008 */

#d				;
twoway  		(rarea cil_08 cih_08 bin if bin>80 & bin<=500 & index==1,sort color(gs13))
				(connected  cdellogincdd_08 bin if bin>80 & bin<=500 & index==1,sort clcolor(red) mcolor(red) msymbol(O) msize(large) lwidth(thick)),
				xtitle(Self-Employment Income in PKR 000s) xtitle(, alignment(top))
				xlabel(100(50)500)
				xline(300, lcolor(maroon) lwidth(thick) lpattern(longdash))
				xline(350, lcolor(green) lwidth(thick) lpattern(longdash))
				xline(400 500, lpattern(dash) lcolor(gs5))
				ytitle(Difference-in-Differences Coefficient) yscale(titlegap(*10))
				ylabel(-0.8(0.4)0.8)
				legend(region(style(none)) label(1 "95% Confidence Interval") label(2 "Coefficient") 
				rows(1) order(2 1)) 
				graphregion(fcolor(white) style(none) color(white) margin(0 2 0 2)) bgcolor(white);
				graph export "$project_graph\FigureAIXPanelA.eps", replace;
#d 				cr
restore

/* COSTS */

preserve
local			var="ncost"
g 				double z0=`var'
g 				z1=F1.`var'
g 				logchange=log(z1/z0)
forvalues		y=2008/2010 {
				local m=substr("`y'",3,2)
g				treat_`m'=(year==`y' & treat==1)
g				cdellogincdd_`m'=0
g				se_`m'=0
g				cil_`m'=0
g				cih_`m'=0
}
g				cdellogincdd_0910=0
g				se_0910=0
g				trend=1
local			i=1
forvalues		y=2007/2011 {
local			i=`i'+1
replace			trend=`i' if year==`y'
}
g				treat_after=(treat==1 & year>2008)
forvalues		b=100(20)500 {
					qui reg logchange trend treat treat_09 treat_10 if bin==`b', cluster(regnor)
					forvalues y=2009/2010 {
						local m=substr("`y'",3,2)
						replace cdellogincdd_`m'=_b[treat_`m'] if bin==`b'
						replace cil_`m'=_b[treat_`m']-1.96*_se[treat_`m'] if bin==`b'
						replace cih_`m'=_b[treat_`m']+1.96*_se[treat_`m'] if bin==`b'
					}
					qui lincom treat_09+treat_10
					replace cdellogincdd_0910=r(estimate) if bin==`b'
					replace se_0910=r(se) if bin==`b'
}

*PLACEBO

forvalues		b=100(20)500 {
				qui reg	logchange trend treat treat_08 treat_09 treat_10 if bin==`b', cluster(regnor)
				replace cdellogincdd_08=_b[treat_08] if bin==`b'
				replace cil_08=_b[treat_08]-1.96*_se[treat_08] if bin==`b'
				replace cih_08=_b[treat_08]+1.96*_se[treat_08] if bin==`b'
}

* AGGREGATE

g 				cil_0910=cdellogincdd_0910-1.96*se_0910 
g 				cih_0910=cdellogincdd_0910+1.96*se_0910 
bys				bin year treat:g index=_n

/* 2010-11 */

#d				;
twoway  		(rarea cil_09 cih_09 bin if bin>80 & bin<=500 & index==1,sort color(gs13))
				(connected  cdellogincdd_09 bin if bin>80 & bin<=500 & index==1,sort clcolor(red) mcolor(red) msymbol(O) msize(large) lwidth(thick))
				(pcarrowi -0.6 170 -0.6 100, lcolor(black) mcolor(black))
				(pcarrowi -0.6 230 -0.6 300, lcolor(black) mcolor(black))
				(pcarrowi -0.6 300 -0.6 350, lcolor(black) mcolor(black))
				(pcarrowi 0.6 420 0.6 400, lcolor(black) mcolor(black))
				(pcarrowi 0.6 480 0.6 500, lcolor(black) mcolor(black)),
				xtitle(Self-Employment Income in PKR 000s) xtitle(, alignment(top))
				xlabel(100(50)500)
				xline(300, lcolor(maroon) lwidth(thick) lpattern(longdash))
				xline(350, lcolor(green) lwidth(thick) lpattern(longdash))
				xline(400 500, lpattern(dash) lcolor(gs5))
				ytitle(Difference-in-Differences Coefficient) yscale(titlegap(*10))
				ylabel(-0.8(0.4)0.8)
				text(0.6 450 "Not-to-zero""tax change")
				text(-0.6 200 "To-zero""tax changes")
				legend(region(style(none)) label(1 "95% Confidence Interval") label(2 "Coefficient") 
				rows(1) order(2 1)) 
				graphregion(fcolor(white) style(none) color(white) margin(0 2 0 2)) bgcolor(white);
				graph export "$project_graph\FigureAVIIIPanelB.eps", replace;
#d 				cr

/* 2008 */

#d				;
twoway  		(rarea cil_08 cih_08 bin if bin>80 & bin<=500 & index==1,sort color(gs13))
				(connected  cdellogincdd_08 bin if bin>80 & bin<=500 & index==1,sort clcolor(red) mcolor(red) msymbol(O) msize(large) lwidth(thick)),
				xtitle(Self-Employment Income in PKR 000s) xtitle(, alignment(top))
				xlabel(100(50)500)
				xline(300, lcolor(maroon) lwidth(thick) lpattern(longdash))
				xline(350, lcolor(green) lwidth(thick) lpattern(longdash))
				xline(400 500, lpattern(dash) lcolor(gs5))
				ytitle(Difference-in-Differences Coefficient) yscale(titlegap(*10))
				ylabel(-0.8(0.4)0.8)
				legend(region(style(none)) label(1 "95% Confidence Interval") label(2 "Coefficient") 
				rows(1) order(2 1)) 
				graphregion(fcolor(white) style(none) color(white) margin(0 2 0 2)) bgcolor(white);
				graph export "$project_graph\FigureAIXPanelB.eps", replace;
#d 				cr
restore

/* PROFIT & LOSS EXPENSES */

preserve
local			var="plexpenses"
g 				double z0=`var'
g 				z1=F1.`var'
g 				logchange=log(z1/z0)
forvalues		y=2008/2010 {
				local m=substr("`y'",3,2)
g				treat_`m'=(year==`y' & treat==1)
g				cdellogincdd_`m'=0
g				se_`m'=0
g				cil_`m'=0
g				cih_`m'=0
}
g				cdellogincdd_0910=0
g				se_0910=0
g				trend=1
local			i=1
forvalues		y=2007/2011 {
local			i=`i'+1
replace			trend=`i' if year==`y'
}
g				treat_after=(treat==1 & year>2008)
forvalues		b=100(20)500 {
					qui reg logchange trend treat treat_09 treat_10 if bin==`b', cluster(regnor)
					forvalues y=2009/2010 {
						local m=substr("`y'",3,2)
						replace cdellogincdd_`m'=_b[treat_`m'] if bin==`b'
						replace cil_`m'=_b[treat_`m']-1.96*_se[treat_`m'] if bin==`b'
						replace cih_`m'=_b[treat_`m']+1.96*_se[treat_`m'] if bin==`b'
					}
					qui lincom treat_09+treat_10
					replace cdellogincdd_0910=r(estimate) if bin==`b'
					replace se_0910=r(se) if bin==`b'
}

*PLACEBO

forvalues		b=100(20)500 {
				qui reg	logchange trend treat treat_08 treat_09 treat_10 if bin==`b', cluster(regnor)
				replace cdellogincdd_08=_b[treat_08] if bin==`b'
				replace cil_08=_b[treat_08]-1.96*_se[treat_08] if bin==`b'
				replace cih_08=_b[treat_08]+1.96*_se[treat_08] if bin==`b'
}

* AGGREGATE

g 				cil_0910=cdellogincdd_0910-1.96*se_0910 
g 				cih_0910=cdellogincdd_0910+1.96*se_0910 
bys				bin year treat:g index=_n

/* 2010-11 */

#d				;
twoway  		(rarea cil_09 cih_09 bin if bin>80 & bin<=500 & index==1,sort color(gs13))
				(connected  cdellogincdd_09 bin if bin>80 & bin<=500 & index==1,sort clcolor(red) mcolor(red) msymbol(O) msize(large) lwidth(thick))
				(pcarrowi -0.6 170 -0.6 100, lcolor(black) mcolor(black))
				(pcarrowi -0.6 230 -0.6 300, lcolor(black) mcolor(black))
				(pcarrowi -0.6 300 -0.6 350, lcolor(black) mcolor(black))
				(pcarrowi 0.6 420 0.6 400, lcolor(black) mcolor(black))
				(pcarrowi 0.6 480 0.6 500, lcolor(black) mcolor(black)),
				xtitle(Self-Employment Income in PKR 000s) xtitle(, alignment(top))
				xlabel(100(50)500)
				xline(300, lcolor(maroon) lwidth(thick) lpattern(longdash))
				xline(350, lcolor(green) lwidth(thick) lpattern(longdash))
				xline(400 500, lpattern(dash) lcolor(gs5))
				ytitle(Difference-in-Differences Coefficient) yscale(titlegap(*10))
				ylabel(-0.8(0.4)0.8)
				text(0.6 450 "Not-to-zero""tax change")
				text(-0.6 200 "To-zero""tax changes")
				legend(region(style(none)) label(1 "95% Confidence Interval") label(2 "Coefficient") 
				rows(1) order(2 1)) 
				graphregion(fcolor(white) style(none) color(white) margin(0 2 0 2)) bgcolor(white);
				graph export "$project_graph\FigureAVIIIPanelC.eps", replace;
#d 				cr

/* 2008 */

#d				;
twoway  		(rarea cil_08 cih_08 bin if bin>80 & bin<=500 & index==1,sort color(gs13))
				(connected  cdellogincdd_08 bin if bin>80 & bin<=500 & index==1,sort clcolor(red) mcolor(red) msymbol(O) msize(large) lwidth(thick)),
				xtitle(Self-Employment Income in PKR 000s) xtitle(, alignment(top))
				xlabel(100(50)500)
				xline(300, lcolor(maroon) lwidth(thick) lpattern(longdash))
				xline(350, lcolor(green) lwidth(thick) lpattern(longdash))
				xline(400 500, lpattern(dash) lcolor(gs5))
				ytitle(Difference-in-Differences Coefficient) yscale(titlegap(*10))
				ylabel(-0.8(0.4)0.8)
				legend(region(style(none)) label(1 "95% Confidence Interval") label(2 "Coefficient") 
				rows(1) order(2 1)) 
				graphregion(fcolor(white) style(none) color(white) margin(0 2 0 2)) bgcolor(white);
				graph export "$project_graph\FigureAIXPanelC.eps", replace;
#d 				cr
restore

/* IMPORTS */

preserve
local			var="imports"
g 				double z0=`var'
g 				z1=F1.`var'
g 				logchange=log(z1/z0)
forvalues		y=2008/2010 {
				local m=substr("`y'",3,2)
g				treat_`m'=(year==`y' & treat==1)
g				cdellogincdd_`m'=0
g				se_`m'=0
g				cil_`m'=0
g				cih_`m'=0
}
g				cdellogincdd_0910=0
g				se_0910=0
g				trend=1
local			i=1
forvalues		y=2007/2011 {
local			i=`i'+1
replace			trend=`i' if year==`y'
}
g				treat_after=(treat==1 & year>2008)
forvalues		b=100(20)500 {
					qui reg logchange trend treat treat_09 treat_10 if bin==`b', cluster(regnor)
					forvalues y=2009/2010 {
						local m=substr("`y'",3,2)
						replace cdellogincdd_`m'=_b[treat_`m'] if bin==`b'
						replace cil_`m'=_b[treat_`m']-1.96*_se[treat_`m'] if bin==`b'
						replace cih_`m'=_b[treat_`m']+1.96*_se[treat_`m'] if bin==`b'
					}
					qui lincom treat_09+treat_10
					replace cdellogincdd_0910=r(estimate) if bin==`b'
					replace se_0910=r(se) if bin==`b'
}

*PLACEBO

forvalues		b=100(20)500 {
				qui reg	logchange trend treat treat_08 treat_09 treat_10 if bin==`b', cluster(regnor)
				replace cdellogincdd_08=_b[treat_08] if bin==`b'
				replace cil_08=_b[treat_08]-1.96*_se[treat_08] if bin==`b'
				replace cih_08=_b[treat_08]+1.96*_se[treat_08] if bin==`b'
}

* AGGREGATE

g 				cil_0910=cdellogincdd_0910-1.96*se_0910 
g 				cih_0910=cdellogincdd_0910+1.96*se_0910 
bys				bin year treat:g index=_n

/* 2010-11 */

#d				;
twoway  		(rarea cil_09 cih_09 bin if bin>80 & bin<=500 & index==1,sort color(gs13))
				(connected  cdellogincdd_09 bin if bin>80 & bin<=500 & index==1,sort clcolor(red) mcolor(red) msymbol(O) msize(large) lwidth(thick))
				(pcarrowi -6 170 -6 100, lcolor(black) mcolor(black))
				(pcarrowi -6 230 -6 300, lcolor(black) mcolor(black))
				(pcarrowi -6 300 -6 350, lcolor(black) mcolor(black))
				(pcarrowi 6 420 6 400, lcolor(black) mcolor(black))
				(pcarrowi 6 480 6 500, lcolor(black) mcolor(black)),
				xtitle(Self-Employment Income in PKR 000s) xtitle(, alignment(top))
				xlabel(100(50)500)
				xline(300, lcolor(maroon) lwidth(thick) lpattern(longdash))
				xline(350, lcolor(green) lwidth(thick) lpattern(longdash))
				xline(400 500, lpattern(dash) lcolor(gs5))
				ytitle(Difference-in-Differences Coefficient) yscale(titlegap(*10))
				ylabel(-10(5)10)
				text(6 450 "Not-to-zero""tax change")
				text(-6 200 "To-zero""tax changes")
				legend(region(style(none)) label(1 "95% Confidence Interval") label(2 "Coefficient") 
				rows(1) order(2 1)) 
				graphregion(fcolor(white) style(none) color(white) margin(0 2 0 2)) bgcolor(white);
				graph export "$project_graph\FigureAVIIIPanelD.eps", replace;
#d 				cr

/* 2008 */

#d				;
twoway  		(rarea cil_08 cih_08 bin if bin>80 & bin<=500 & index==1,sort color(gs13))
				(connected  cdellogincdd_08 bin if bin>80 & bin<=500 & index==1,sort clcolor(red) mcolor(red) msymbol(O) msize(large) lwidth(thick)),
				xtitle(Self-Employment Income in PKR 000s) xtitle(, alignment(top))
				xlabel(100(50)500)
				xline(300, lcolor(maroon) lwidth(thick) lpattern(longdash))
				xline(350, lcolor(green) lwidth(thick) lpattern(longdash))
				xline(400 500, lpattern(dash) lcolor(gs5))
				ytitle(Difference-in-Differences Coefficient) yscale(titlegap(*10))
				ylabel(-10(5)10)
				legend(region(style(none)) label(1 "95% Confidence Interval") label(2 "Coefficient") 
				rows(1) order(2 1)) 
				graphregion(fcolor(white) style(none) color(white) margin(0 2 0 2)) bgcolor(white);
				graph export "$project_graph\FigureAIXPanelD.eps", replace;
#d 				cr
restore

/* OPENING STOCK */

preserve
local			var="openingstock"
g 				double z0=`var'
g 				z1=F1.`var'
g 				logchange=log(z1/z0)
forvalues		y=2008/2010 {
				local m=substr("`y'",3,2)
g				treat_`m'=(year==`y' & treat==1)
g				cdellogincdd_`m'=0
g				se_`m'=0
g				cil_`m'=0
g				cih_`m'=0
}
g				cdellogincdd_0910=0
g				se_0910=0
g				trend=1
local			i=1
forvalues		y=2007/2011 {
local			i=`i'+1
replace			trend=`i' if year==`y'
}
g				treat_after=(treat==1 & year>2008)
forvalues		b=100(20)500 {
					qui reg logchange trend treat treat_09 treat_10 if bin==`b', cluster(regnor)
					forvalues y=2009/2010 {
						local m=substr("`y'",3,2)
						replace cdellogincdd_`m'=_b[treat_`m'] if bin==`b'
						replace cil_`m'=_b[treat_`m']-1.96*_se[treat_`m'] if bin==`b'
						replace cih_`m'=_b[treat_`m']+1.96*_se[treat_`m'] if bin==`b'
					}
					qui lincom treat_09+treat_10
					replace cdellogincdd_0910=r(estimate) if bin==`b'
					replace se_0910=r(se) if bin==`b'
}

*PLACEBO

forvalues		b=100(20)500 {
				qui reg	logchange trend treat treat_08 treat_09 treat_10 if bin==`b', cluster(regnor)
				replace cdellogincdd_08=_b[treat_08] if bin==`b'
				replace cil_08=_b[treat_08]-1.96*_se[treat_08] if bin==`b'
				replace cih_08=_b[treat_08]+1.96*_se[treat_08] if bin==`b'
}

* AGGREGATE

g 				cil_0910=cdellogincdd_0910-1.96*se_0910 
g 				cih_0910=cdellogincdd_0910+1.96*se_0910 
bys				bin year treat:g index=_n

/* 2010-11 */

#d				;
twoway  		(rarea cil_09 cih_09 bin if bin>80 & bin<=500 & index==1,sort color(gs13))
				(connected  cdellogincdd_09 bin if bin>80 & bin<=500 & index==1,sort clcolor(red) mcolor(red) msymbol(O) msize(large) lwidth(thick))
				(pcarrowi -0.6 170 -0.6 100, lcolor(black) mcolor(black))
				(pcarrowi -0.6 230 -0.6 300, lcolor(black) mcolor(black))
				(pcarrowi -0.6 300 -0.6 350, lcolor(black) mcolor(black))
				(pcarrowi 0.6 420 0.6 400, lcolor(black) mcolor(black))
				(pcarrowi 0.6 480 0.6 500, lcolor(black) mcolor(black)),
				xtitle(Self-Employment Income in PKR 000s) xtitle(, alignment(top))
				xlabel(100(50)500)
				xline(300, lcolor(maroon) lwidth(thick) lpattern(longdash))
				xline(350, lcolor(green) lwidth(thick) lpattern(longdash))
				xline(400 500, lpattern(dash) lcolor(gs5))
				ytitle(Difference-in-Differences Coefficient) yscale(titlegap(*10))
				ylabel(-0.8(0.4)0.8)
				text(0.6 450 "Not-to-zero""tax change")
				text(-0.6 200 "To-zero""tax changes")
				legend(region(style(none)) label(1 "95% Confidence Interval") label(2 "Coefficient") 
				rows(1) order(2 1)) 
				graphregion(fcolor(white) style(none) color(white) margin(0 2 0 2)) bgcolor(white);
				graph export "$project_graph\FigureAVIIIPanelE.eps", replace;
#d 				cr

/* 2008 */

#d				;
twoway  		(rarea cil_08 cih_08 bin if bin>80 & bin<=500 & index==1,sort color(gs13))
				(connected  cdellogincdd_08 bin if bin>80 & bin<=500 & index==1,sort clcolor(red) mcolor(red) msymbol(O) msize(large) lwidth(thick)),
				xtitle(Self-Employment Income in PKR 000s) xtitle(, alignment(top))
				xlabel(100(50)500)
				xline(300, lcolor(maroon) lwidth(thick) lpattern(longdash))
				xline(350, lcolor(green) lwidth(thick) lpattern(longdash))
				xline(400 500, lpattern(dash) lcolor(gs5))
				ytitle(Difference-in-Differences Coefficient) yscale(titlegap(*10))
				ylabel(-0.8(0.4)0.8)
				legend(region(style(none)) label(1 "95% Confidence Interval") label(2 "Coefficient") 
				rows(1) order(2 1)) 
				graphregion(fcolor(white) style(none) color(white) margin(0 2 0 2)) bgcolor(white);
				graph export "$project_graph\FigureAIXPanelE.eps", replace;
#d 				cr
restore

/* CLOSING STOCK */

preserve
local			var="closingstock"
g 				double z0=`var'
g 				z1=F1.`var'
g 				logchange=log(z1/z0)
forvalues		y=2008/2010 {
				local m=substr("`y'",3,2)
g				treat_`m'=(year==`y' & treat==1)
g				cdellogincdd_`m'=0
g				se_`m'=0
g				cil_`m'=0
g				cih_`m'=0
}
g				cdellogincdd_0910=0
g				se_0910=0
g				trend=1
local			i=1
forvalues		y=2007/2011 {
local			i=`i'+1
replace			trend=`i' if year==`y'
}
g				treat_after=(treat==1 & year>2008)
forvalues		b=100(20)500 {
					qui reg logchange trend treat treat_09 treat_10 if bin==`b', cluster(regnor)
					forvalues y=2009/2010 {
						local m=substr("`y'",3,2)
						replace cdellogincdd_`m'=_b[treat_`m'] if bin==`b'
						replace cil_`m'=_b[treat_`m']-1.96*_se[treat_`m'] if bin==`b'
						replace cih_`m'=_b[treat_`m']+1.96*_se[treat_`m'] if bin==`b'
					}
					qui lincom treat_09+treat_10
					replace cdellogincdd_0910=r(estimate) if bin==`b'
					replace se_0910=r(se) if bin==`b'
}

*PLACEBO

forvalues		b=100(20)500 {
				qui reg	logchange trend treat treat_08 treat_09 treat_10 if bin==`b', cluster(regnor)
				replace cdellogincdd_08=_b[treat_08] if bin==`b'
				replace cil_08=_b[treat_08]-1.96*_se[treat_08] if bin==`b'
				replace cih_08=_b[treat_08]+1.96*_se[treat_08] if bin==`b'
}

* AGGREGATE

g 				cil_0910=cdellogincdd_0910-1.96*se_0910 
g 				cih_0910=cdellogincdd_0910+1.96*se_0910 
bys				bin year treat:g index=_n

/* 2010-11 */

#d				;
twoway  		(rarea cil_09 cih_09 bin if bin>80 & bin<=500 & index==1,sort color(gs13))
				(connected  cdellogincdd_09 bin if bin>80 & bin<=500 & index==1,sort clcolor(red) mcolor(red) msymbol(O) msize(large) lwidth(thick))
				(pcarrowi -0.6 170 -0.6 100, lcolor(black) mcolor(black))
				(pcarrowi -0.6 230 -0.6 300, lcolor(black) mcolor(black))
				(pcarrowi -0.6 300 -0.6 350, lcolor(black) mcolor(black))
				(pcarrowi 0.6 420 0.6 400, lcolor(black) mcolor(black))
				(pcarrowi 0.6 480 0.6 500, lcolor(black) mcolor(black)),
				xtitle(Self-Employment Income in PKR 000s) xtitle(, alignment(top))
				xlabel(100(50)500)
				xline(300, lcolor(maroon) lwidth(thick) lpattern(longdash))
				xline(350, lcolor(green) lwidth(thick) lpattern(longdash))
				xline(400 500, lpattern(dash) lcolor(gs5))
				ytitle(Difference-in-Differences Coefficient) yscale(titlegap(*10))
				ylabel(-0.8(0.4)0.8)
				text(0.6 450 "Not-to-zero""tax change")
				text(-0.6 200 "To-zero""tax changes")
				legend(region(style(none)) label(1 "95% Confidence Interval") label(2 "Coefficient") 
				rows(1) order(2 1)) 
				graphregion(fcolor(white) style(none) color(white) margin(0 2 0 2)) bgcolor(white);
				graph export "$project_graph\FigureAVIIIPanelF.eps", replace;
#d 				cr

/* 2008 */

#d				;
twoway  		(rarea cil_08 cih_08 bin if bin>80 & bin<=500 & index==1,sort color(gs13))
				(connected  cdellogincdd_08 bin if bin>80 & bin<=500 & index==1,sort clcolor(red) mcolor(red) msymbol(O) msize(large) lwidth(thick)),
				xtitle(Self-Employment Income in PKR 000s) xtitle(, alignment(top))
				xlabel(100(50)500)
				xline(300, lcolor(maroon) lwidth(thick) lpattern(longdash))
				xline(350, lcolor(green) lwidth(thick) lpattern(longdash))
				xline(400 500, lpattern(dash) lcolor(gs5))
				ytitle(Difference-in-Differences Coefficient) yscale(titlegap(*10))
				ylabel(-0.8(0.4)0.8)
				legend(region(style(none)) label(1 "95% Confidence Interval") label(2 "Coefficient") 
				rows(1) order(2 1)) 
				graphregion(fcolor(white) style(none) color(white) margin(0 2 0 2)) bgcolor(white);
				graph export "$project_graph\FigureAIXPanelF.eps", replace;
#d 				cr
restore
